home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
COMPILER
/
SATHER
/
!Sather
/
Library
/
IO
/
sa
/
str_stream
< prev
next >
Wrap
Text File
|
1996-04-09
|
2KB
|
48 lines
---------------------------> Sather 1.1 source file <--------------------------
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: str_stream.sa,v 1.2 1996/04/09 10:05:57 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
-------------------------------------------------------------------
class STR_STREAM < $OSTREAM, $STR is
-- An output stream that writes out to a string (an FSTR, for
-- efficiency). Very similar to a file.
--
-- Usage:
-- write_to_stream(o: $OUTSTREAM) is
-- o + "this is a test";
-- end;
-- Which can be invoked using:
-- s: STR_STREAM := #;
-- write_to_stream(s);
-- write_to_stream(s);
-- s.str then would have two copies of "this is a test" in it.
private attr f: FSTR;
create: SAME is
-- Create a new stream
res ::= new;
res.f := #FSTR("");
return res;
end;
plus(s: $STR): SAME is
-- Append the string "s" to self
f := f+s.str;
return self;
end;
plus(s: $STR) is discard ::= plus(s) end;
str: STR is return f.str; end;
end; -- class STR_STREAM
-------------------------------------------------------------------